package com.millstein.realtime.function;

import com.millstein.realtime.util.IkUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.util.List;

/**
 * @Description
 * @Author tsing
 * @Date 2024-10-17 16:12
 */
@FunctionHint(output = @DataTypeHint("row(rs string)"))
public class IkAnalyzer extends TableFunction<Row> {

    public void eval(String keyword) {
        List<String> ikWords = IkUtil.split(keyword, false);
        for (String ikWord : ikWords) {
            if (ikWord != null && !"".equals(ikWord.trim())) {
                collect(Row.of(ikWord));
            }
        }
    }
}
